import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '门店编码',
    align: 'center',
    dataIndex: 'storeCode',
    width: 120,
  },
  {
    title: '门店名称',
    align: 'center',
    dataIndex: 'storeName',
    width: 120,
  },
  {
    title: '门店类型',
    align: 'center',
    dataIndex: 'storeType',
    width: 80,
    helpMessage: '直营或者加盟',
    ifShow: false,
  },
  {
    title: '渠道类型',
    align: 'center',
    dataIndex: 'customerTypeCode',
    width: 80,
    ifShow: false,
  },
  {
    title: '渠道类型',
    align: 'center',
    dataIndex: 'customerType',
    width: 80,
  },
  {
    title: '门店等级',
    align: 'center',
    dataIndex: 'storeLevel_dictText',
    width: 80,
    ifShow: false,
  },
  // {
  //   title: '省市区',
  //   align: 'center',
  //   dataIndex: 'province',
  //   width: 150,
  // },
  {
    title: '门店详细地址',
    align: 'center',
    dataIndex: 'storeAddress',
    width: 200,
  },
  {
    title: '门店地址经纬度',
    align: 'center',
    dataIndex: 'storeCoordinates',
    ifShow: false,
  },
  {
    title: '门店面积',
    align: 'center',
    dataIndex: 'storeArea',
    ifShow: false,
  },
  {
    title: '负责人',
    align: 'center',
    dataIndex: 'storeManager',
    width: 100,
  },
  {
    title: '负责人电话',
    align: 'center',
    dataIndex: 'storeManagerPhone',
    width: 100,
  },
  // {
  //   title: '发货方式',
  //   align: 'center',
  //   dataIndex: 'deliveryWay_dictText',
  //   ifShow: false,
  // },
  // {
  //   title: '快递类型',
  //   align: 'center',
  //   dataIndex: 'deliveryType_dictText',
  //   ifShow: false,
  // },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '门店编码',
    field: 'storeCode',
    component: 'JInput',
  },
  {
    label: '门店名称',
    field: 'storeName',
    component: 'JInput',
  },
  {
    label: '城市',
    field: 'city',
    component: 'JInput',
  },
  // {
  //   label: '渠道',
  //   field: 'customerTypeCode',
  //   component: 'JDictSelectTag',
  //   componentProps: {
  //     dictCode: 'xl_customer_type,type_desc,type_code',
  //   },
  // },
  // {
  //   label: '门店等级',
  //   field: 'storeLevel',
  //   component: 'JDictSelectTag',
  //   componentProps: {
  //     dictCode: 'xlcustomerlevel',
  //   },
  // },
  {
    label: '门店负责人',
    field: 'storeManager',
    component: 'JInput',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '门店编码',
    field: 'storeCode',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '门店名称',
    field: 'storeName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入门店名称!' }];
    },
  },
  {
    label: '门店类型',
    field: 'storeType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'xl_store_type',
      type: 'radioButton',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '门店类型!' }];
    },
  },
  {
    label: '渠道描述',
    field: 'customerType',
    component: 'Input',
    slot: 'customerTypeCode',
    required: true,
  },
  {
    label: '渠道编码',
    field: 'customerTypeCode',
    component: 'Input',
    required: true,
    dynamicDisabled: true,
  },
  {
    label: '门店等级',
    field: 'storeLevel',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'xlcustomerlevel',
      type: 'radioButton',
    },
    dynamicDisabled: true,
  },
  // {
  //   label: '省市区',
  //   field: 'province',
  //   component: 'JAreaLinkage',
  //   componentProps: {
  //     saveCode: 'region',
  //   },
  //   dynamicRules: ({ model, schema }) => {
  //     return [{ required: true, message: '请输入省市区!' }];
  //   },
  // },
  {
    label: '省市区',
    field: 'province',
    component: 'Input',
    slot: 'provinceSlot',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true }];
    },
    show: true,
  },
  {
    label: '市',
    field: 'city',
    component: 'Input',
    show: false,
  },
  {
    label: '区',
    field: 'district',
    component: 'Input',
    show: false,
  },
  {
    label: '门店详细地址',
    field: 'storeAddress',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入门店详细地址!' }];
    },
  },
  // {
  //   label: '门店地址经纬度',
  //   field: 'storeCoordinates',
  //   component: 'Input',
  // },
  // {
  //   label: '门店面积',
  //   field: 'storeArea',
  //   component: 'Input',
  // },
  {
    label: '门店负责人',
    field: 'storeManager',
    component: 'Input',
    slot: 'storeManager',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入门店负责人!' }];
    },
  },
  {
    label: '门店负责人电话',
    field: 'storeManagerPhone',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入门店负责人电话!' }];
    },
  },

  {
    label: '发货方式',
    field: 'deliveryWay',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'delivery_way',
      type: 'radioButton',
    },
  },
  {
    label: '快递类型',
    field: 'deliveryType',
    component: 'JDictSelectTag',
    ifShow: ({ values }) => values.deliveryWay === '2',
    componentProps: {
      dictCode: 'delivery_type',
    },
  },

  {
    label: '门店负责人id',
    field: 'storeManagerId',
    component: 'Input',
    show: false,
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
//子表单数据
//子表表格配置
export const xlCustomerMystoreColumns: JVxeColumn[] = [
  {
    title: '用户id',
    key: 'userId',
    type: JVxeTypes.hidden,
  },
  {
    title: '用户名',
    key: 'userName',
    // type: JVxeTypes.userSelect,
    type: JVxeTypes.slot,
    slotName: 'userName',
    width:"200px",
    // props: { 
    //   isRadioSelection: true,
    // },
    placeholder: '请选择${title}',
    titlePrefix: {
      icon: 'vxe-cell--required-icon',
    },
    validateRules: [{ required: true, message: '${title}不能为空' }],
  },
  {
    title: '手机号',
    key: 'phone',
    type: JVxeTypes.normal,
    width: '200px',
  },
];

// 高级查询数据
export const superQuerySchema = {
  storeCode: { title: '门店编码', order: 0, view: 'text', type: 'string' },
  storeName: { title: '门店名称', order: 1, view: 'text', type: 'string' },
  storeType: { title: '门店类型：直营，加盟', order: 2, view: 'text', type: 'string' },
  storeLevel: { title: '门店等级：一批，二批，三批', order: 3, view: 'radio', type: 'string', dictCode: 'xlcustomerlevel' },
  province: { title: '省市区', order: 5, view: 'pca', type: 'string' },
  storeAddress: { title: '门店详细地址', order: 6, view: 'text', type: 'string' },
  storeCoordinates: { title: '门店地址经纬度', order: 7, view: 'text', type: 'string' },
  storeArea: { title: '门店面积', order: 8, view: 'text', type: 'string' },
  storeManager: { title: '门店负责人', order: 9, view: 'text', type: 'string' },
  storeManagerPhone: { title: '门店负责人电话', order: 10, view: 'text', type: 'string' },
  //子表高级查询
  xlCustomerMystore: {
    title: '客户门店工作人员',
    view: 'table',
    fields: {
      userName: { title: '用户名', order: 0, view: 'sel_user', type: 'string' },
    },
  },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
